# -*- coding: utf-8 -*-

# @File  : demo.py
# @Author: Lomo
# @Site  : lomo.space
# @Date  : 2019-11-27
# @Desc  :


import datetime

from model.db import DB
from model.supplier_star import SupplierStar
from model.t_supplier import TSupplier

from controller.supplier_star import SupplierStarCal

from utils.csv import CSV
from cron.score_ten import score_ten_sell, sell_operate_ten

if __name__ == '__main__':

    supplier_star = SupplierStar()
    # res = supplier_star.get_supplier_by_id('3003346')
    # # score_date: <class 'datetime.date'>
    # # create_time: <class 'datetime.datetime'>
    # for obj in res:
    #     # print(len(obj))  # 32
    #     print(obj[0], obj[30], obj[25])  # score_date, sell

    # suppliers = supplier_star.get_suppliers_by_date(date='2019-11-26')
    # print(len(suppliers))
    #
    # max_i = supplier_star.get_max_index_by_date('tms_24', '2019-11-21')
    # print(max_i[0])  # 100.00000

    tmp = supplier_star.get_by_index_id_date(index_name='tms_24', supplier_id=2597039,
                                             date='2019-12-02')
    # print(tmp[0])

    # 计算某个商家某一天的 tms_24, 24H揽件率
    # print(SupplierStarCal().tms_24(supplier_id=2597039, date='2019-12-02'))
    # 逆向指标
    print(SupplierStarCal().tms_timeout(supplier_id=3013265, date='2019-12-02'))

    # t = TSupplier()
    # res = t.get_type_by_supplier_id(supplier_id='0')
    # print(res[0])

    # 获取供应商合作类型
    # res = TSupplier.get_coop_type_by_id(id_=10)
    # print(res)

    # 获取总供应商数: 1、自营, 2、POP
    # print(TSupplier.get_totals_by_type(coop_type=1))
    # print(t.get_total_count_by_type(coop_type=2)[0])

    # supplier_id = 100
    # t1 = TSupplier.get_coop_type_by_id(id_=supplier_id)
    # print(t1)


    # import os
    # project_dir = os.path.dirname(os.path.abspath(__file__))
    # print(project_dir)  # /Users/lomo/Mryt/qa/dsr

    # cs = CSV()
    # sxx = cs.create_csv()
    # print(sxx)

    # date = '2019-11-27'
    # score_ten_sell(date=date)
    # sell_operate_ten(date=date)

